import json
import time
import ast
import requests
from util.headers import get_header

time_temp = int(time.time() * 1000)
url = f"https://product.weather.com.cn/alarm/grepalarm_cn.php?_={time_temp}"
res = requests.get(url, headers=get_header("https://www.weather.com.cn/"))
content_data = json.loads(res.content.decode()[14:-1])
for data in content_data["data"]:
    # print(data)
    detail_url = f"https://product.weather.com.cn/alarm/webdata/{data[1]}?_={time_temp}"
    detail_res = requests.get(
        detail_url, headers=get_header("https://www.weather.com.cn/")
    )
    detail_data = json.loads(detail_res.content.decode("utf-8")[14:])
    print(detail_data)
